
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>基于docker运行Jenkins · Dr. Zhou's HOME</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.2">
        <meta name="author" content="Zhou Wei">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-prism/prism-coy.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-advanced-emoji/emojify.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-ace/ace.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-emphasize/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-katex/katex.min.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-sectionx/sectionx.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-codeblock-filename/block.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-local-video/video-js.min.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-image-captions/image-captions.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="aliyun.html" />
    
    
    <link rel="prev" href="dockerTomcat.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="http://weizhou.coding.me/weizhou/intro/" target="_blank" class="custom-link">周炜主页</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    学术研究
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../../lecture/lecture.html">
            
                <a href="../../lecture/lecture.html">
            
                    
                    教学课程
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../../lecture/java/java.html">
            
                <a href="../../lecture/java/java.html">
            
                    
                    Java程序设计
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1.1" data-path="../../lecture/java/javaCode.html">
            
                <a href="../../lecture/java/javaCode.html">
            
                    
                    课件代码
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../../lecture/jsp/jsp.html">
            
                <a href="../../lecture/jsp/jsp.html">
            
                    
                    JSP开发技术
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.2.1" data-path="../../lecture/jsp/jspCode.html">
            
                <a href="../../lecture/jsp/jspCode.html">
            
                    
                    课件代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2.2" data-path="../../lecture/jsp/videos.html">
            
                <a href="../../lecture/jsp/videos.html">
            
                    
                    课程视频
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../../lecture/ssh/ssh.html">
            
                <a href="../../lecture/ssh/ssh.html">
            
                    
                    Java Web框架开发技术
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.3.1" data-path="../../lecture/ssh/sshCode.html">
            
                <a href="../../lecture/ssh/sshCode.html">
            
                    
                    课件代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3.2" data-path="../../lecture/ssh/videos.html">
            
                <a href="../../lecture/ssh/videos.html">
            
                    
                    课程视频
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3.3" data-path="../../lecture/ssh/sshHomework.html">
            
                <a href="../../lecture/ssh/sshHomework.html">
            
                    
                    作业及测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3.4" data-path="../../lecture/ssh/maven/mavenPPT.html">
            
                <a href="../../lecture/ssh/maven/mavenPPT.html">
            
                    
                    Maven简介
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../programmingNote.html">
            
                <a href="../programmingNote.html">
            
                    
                    软件开发
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../develop/developNote.html">
            
                <a href="../develop/developNote.html">
            
                    
                    开发总结
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" >
            
                <span>
            
                    
                    Struts2
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.2.1" data-path="../struts/strutsNote.html">
            
                <a href="../struts/strutsNote.html">
            
                    
                    笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.2" data-path="../struts/strutsBug.html">
            
                <a href="../struts/strutsBug.html">
            
                    
                    坑
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.3" >
            
                <span>
            
                    
                    springMVC
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.3.1" data-path="../springmvc/springmvcNote.html">
            
                <a href="../springmvc/springmvcNote.html">
            
                    
                    笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3.2" data-path="../springmvc/springmvcBug.html">
            
                <a href="../springmvc/springmvcBug.html">
            
                    
                    坑
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.4" >
            
                <span>
            
                    
                    Spring
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.4.1" data-path="../spring/springNote.html">
            
                <a href="../spring/springNote.html">
            
                    
                    笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.2" data-path="../spring/springBug.html">
            
                <a href="../spring/springBug.html">
            
                    
                    坑
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.5" >
            
                <span>
            
                    
                    Hibernate
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.5.1" data-path="../hibernate/hibernateNote.html">
            
                <a href="../hibernate/hibernateNote.html">
            
                    
                    笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.2" data-path="../hibernate/hibernateBug.html">
            
                <a href="../hibernate/hibernateBug.html">
            
                    
                    坑
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.6" >
            
                <span>
            
                    
                    weex
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.6.1" >
            
                <span>
            
                    
                    笔记
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6.2" data-path="../weex/problems.html">
            
                <a href="../weex/problems.html">
            
                    
                    坑
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.7" >
            
                <span>
            
                    
                    前端技术
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.7.1" data-path="../web/webNote.html">
            
                <a href="../web/webNote.html">
            
                    
                    笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7.2" data-path="../web/webBug.html">
            
                <a href="../web/webBug.html">
            
                    
                    坑
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.8" >
            
                <span>
            
                    
                    持续集成CI
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.8.1" data-path="../jenkins/jenkinsNote.html">
            
                <a href="../jenkins/jenkinsNote.html">
            
                    
                    Jenkins
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.9" >
            
                <span>
            
                    
                    运维
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.9.1" data-path="aws.html">
            
                <a href="aws.html">
            
                    
                    AWS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.9.2" data-path="dockerTomcat.html">
            
                <a href="dockerTomcat.html">
            
                    
                    基于docker运行Tomcat/MySql
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.9.3" data-path="dockerJenkins.html">
            
                <a href="dockerJenkins.html">
            
                    
                    基于docker运行Jenkins
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.9.4" data-path="aliyun.html">
            
                <a href="aliyun.html">
            
                    
                    阿里云构建服务器
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.10" >
            
                <span>
            
                    
                    Tools
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.10.1" data-path="../eclipse/eclipseNote.html">
            
                <a href="../eclipse/eclipseNote.html">
            
                    
                    Eclipse
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.10.2" data-path="../idea/ideaNote.html">
            
                <a href="../idea/ideaNote.html">
            
                    
                    IDEA
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.10.3" data-path="../vim/vimNote.html">
            
                <a href="../vim/vimNote.html">
            
                    
                    vim
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.11" >
            
                <span>
            
                    
                    项目分析
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.11.1" >
            
                <span>
            
                    
                    电子商场
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.11.1.1" data-path="../projSrc/wemall/basics.html">
            
                <a href="../projSrc/wemall/basics.html">
            
                    
                    基础功能
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.12" >
            
                <span>
            
                    
                    Scrapy
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.12.1" data-path="../scrapy/scrapyNote.html">
            
                <a href="../scrapy/scrapyNote.html">
            
                    
                    Note
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    学生讲座
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../../stutalks/worldIntro/worldIntroPPT.html">
            
                <a href="../../stutalks/worldIntro/worldIntroPPT.html">
            
                    
                    我对三观的一些思考
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    我的解决方案
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../../solution/dpt/ref.html">
            
                <a href="../../solution/dpt/ref.html">
            
                    
                    DPT-S1解决方案
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1.1" data-path="../../solution/dpt/webdav.html">
            
                <a href="../../solution/dpt/webdav.html">
            
                    
                    WebDav
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.2" data-path="../../solution/dpt/display.html">
            
                <a href="../../solution/dpt/display.html">
            
                    
                    Dpt当显示器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.3" data-path="../../solution/dpt/root.html">
            
                <a href="../../solution/dpt/root.html">
            
                    
                    破解
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../../solution/gitbook/gitbookReadme.html">
            
                <a href="../../solution/gitbook/gitbookReadme.html">
            
                    
                    gitBook解决方案
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.2.1" data-path="../../solution/gitbook/exp.html">
            
                <a href="../../solution/gitbook/exp.html">
            
                    
                    gitbook经验
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.2" data-path="../../solution/gitbook/error.html">
            
                <a href="../../solution/gitbook/error.html">
            
                    
                    gitBook坑
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.3" data-path="../../solution/gitbook/script.html">
            
                <a href="../../solution/gitbook/script.html">
            
                    
                    gitBook脚本
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.4" data-path="../../solution/gitbook/awsDocker.html">
            
                <a href="../../solution/gitbook/awsDocker.html">
            
                    
                    使用docker构建gitbook服务器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.5" data-path="../../solution/gitbook/atom.html">
            
                <a href="../../solution/gitbook/atom.html">
            
                    
                    markdown编辑器Atom
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.6" data-path="../../solution/gitbook/ieee.html">
            
                <a href="../../solution/gitbook/ieee.html">
            
                    
                    使用markdown写IEEE论文
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >基于docker运行Jenkins</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x4F7F;&#x7528;docker&#x6784;&#x5EFA;jenkins&#x955C;&#x50CF;">1. &#x4F7F;&#x7528;Docker&#x6784;&#x5EFA;Jenkins&#x955C;&#x50CF;</h1>
<p>&#x53C2;&#x7167;<a href="http://dockone.io/article/431?utm_source=tuicool&amp;utm_medium=referral" target="_blank">&#x5728;&#xFF08;Docker&#x91CC;&#x7684;&#xFF09;Jenkins&#x91CC;&#x8FD0;&#x884C;Docker</a>&#x548C;<a href="https://github.com/jenkinsci/docker" target="_blank">Official Jenkins Docker image</a></p>
<ul>
<li>&#x76EE;&#x7684;&#xFF1A;&#x5728;&#x4F7F;&#x7528;docker&#x8FD0;&#x884C;gitbookServer&#xFF0C;Tomcat&#xFF0C;Mysql&#x7684;&#x57FA;&#x7840;&#x4E0A;&#xFF0C;&#x7EE7;&#x7EED;&#x4F7F;&#x7528;docker&#x8FD0;&#x884C;Jenkins&#xFF0C;&#x8FD9;&#x6837;aws&#x4E0A;&#x6240;&#x6709;&#x7684;&#x670D;&#x52A1;&#x90FD;&#x8FD0;&#x884C;&#x5728;&#x5BB9;&#x5668;&#x4E2D;</li>
</ul>
<h2 id="&#x6784;&#x5EFA;jenkins&#x955C;&#x50CF;">1.1. &#x6784;&#x5EFA;Jenkins&#x955C;&#x50CF;</h2>
<p>&#x6211;&#x7684;&#x5305;&#x542B;&#x63D2;&#x4EF6;&#x7684;jenkins&#x7684;Dockerfile&#x6587;&#x4EF6;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code>FROM jenkins

USER root
RUN apt-get update \
  &amp;&amp; apt-get install -y sudo maven\
  &amp;&amp; apt-get install -y sudo vim\
  &amp;&amp; rm -rf /var/lib/apt/lists/*
RUN echo &quot;jenkins ALL=NOPASSWD: ALL&quot; &gt;&gt; /etc/sudoers

USER jenkins
RUN /usr/local/bin/install-plugins.sh bouncycastle-api:2.16.0 cloudbees-folder:5.17 structs:1.6 junit:1.20 antisamy-markup-formatter:1.5 pam-auth:1.3 windows-slaves:1.2 display-url-api:1.1.1 mailer:1.19 ldap:1.14 icon-shim:2.0.3 matrix-auth:1.4 token-macro:2.0 script-security:1.26 matrix-project:1.8 external-monitor-job:1.7 build-timeout:1.18 credentials:2.1.11 plain-credentials:1.4 workflow-step-api:2.9 credentials-binding:1.10 timestamper:1.8.8 resource-disposer:0.6 scm-api:2.0.7 workflow-api:2.11 workflow-basic-steps:2.4 ws-cleanup:0.32 ant:1.4 gradle:1.26 workflow-scm-step:2.3 ssh-credentials:1.13 git-client:2.2.1 jquery-detached:1.2.1 workflow-support:2.13 ace-editor:1.1 workflow-cps:2.27 git-server:1.7 workflow-cps-global-lib:2.6 pipeline-milestone-step:1.3 pipeline-build-step:2.4 pipeline-stage-step:2.2 pipeline-input-step:2.5 workflow-job:2.10 pipeline-graph-analysis:1.3 pipeline-rest-api:2.5 handlebars:1.1.1 momentjs:1.1.1 pipeline-stage-view:2.5 durable-task:1.13 workflow-durable-task-step:2.9 pipeline-model-api:1.0.2 pipeline-stage-tags-metadata:1.0.2 authentication-tokens:1.3 docker-commons:1.6 docker-workflow:1.10 pipeline-model-declarative-agent:1.0.2 branch-api:2.0.6 workflow-multibranch:2.12 pipeline-model-definition:1.0.2 workflow-aggregator:2.5 github-api:1.84 git:3.0.5 github:1.26.0 github-branch-source:2.0.3 pipeline-github-lib:1.0 github-organization-folder:1.6 mapdb-api:1.0.9.0 subversion:2.7.1 ssh-slaves:1.13 email-ext:2.57 build-token-root:1.4 thinBackup:1.9
</code></pre><ul>
<li><p>&#x6784;&#x5EFA;jenkins&#x955C;&#x50CF;</p>
<blockquote>
<p>sudo docker build -t weizhou/jenkins .</p>
</blockquote>
</li>
<li><p>&#x8FD9;&#x662F;&#x4E00;&#x4E2A;debian&#x7CFB;&#x7EDF;&#xFF0C;maven&#x7684;&#x5B89;&#x88C5;&#x76EE;&#x5F55;&#x4E3A;</p>
<blockquote>
<p>/usr/share/maven</p>
</blockquote>
</li>
<li>maven&#x672C;&#x5730;&#x4ED3;&#x5E93;&#x5728;<blockquote>
<p>/usr/share/maven-repo</p>
</blockquote>
</li>
</ul>
<h1 id="&#x4F7F;&#x7528;docker&#x955C;&#x50CF;&#x8FD0;&#x884C;gitbook&#x670D;&#x52A1;&#x5BB9;&#x5668;">2. &#x4F7F;&#x7528;Docker&#x955C;&#x50CF;&#x8FD0;&#x884C;gitbook&#x670D;&#x52A1;&#x5BB9;&#x5668;</h1>
<ul>
<li>&#x8FD0;&#x884C;jenkins&#x955C;&#x50CF;<blockquote>
<p>sudo docker run --name jenkins -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker -d weizhou/jenkins</p>
</blockquote>
</li>
<li>&#x67E5;&#x770B;&#x521D;&#x59CB;&#x5BC6;&#x7801;<blockquote>
<p>sudo docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword</p>
</blockquote>
</li>
</ul>
<ul>
<li><p>&#x6D4F;&#x89C8;&#x5668;&#x4E2D;&#x670D;&#x52A1;&#x5668;8080&#x7AEF;&#x53E3;&#x8FD0;&#x884C;jenkins&#x4E86;&#xFF0C;jenkins&#x4EFB;&#x52A1;&#x4E2D;&#x6784;&#x5EFA;&#xFF0C;&#x9009;&#x62E9;<code>Execute shell</code>&#xFF0C;&#x586B;&#x5165;&#xFF1A;</p>
<blockquote>
<p>sudo docker run --rm weizhou/gitbookserver1:ssh /root/weizhougitbooks/weizhou/gbbuild.sh
sudo docker run --rm weizhou/gitbookserver1:notpull_gitbook /root/weizhougitbooks/gitbook/gbbuild.sh</p>
<h1 id="&#x4F7F;&#x7528;docker&#x955C;&#x50CF;&#x8FD0;&#x884C;tomcat&#x670D;&#x52A1;&#x5BB9;&#x5668;">3. &#x4F7F;&#x7528;Docker&#x955C;&#x50CF;&#x8FD0;&#x884C;Tomcat&#x670D;&#x52A1;&#x5BB9;&#x5668;</h1>
</blockquote>
</li>
<li><p>&#x521B;&#x5EFA;&#x653E;&#x7F6E;sql&#x6570;&#x636E;&#x7684;&#x76EE;&#x5F55;</p>
<blockquote>
<p>mkdir mysqlData</p>
</blockquote>
</li>
<li><p>&#x542F;&#x52A8;Mysql&#x670D;&#x52A1;&#x5668;</p>
<blockquote>
<p>sudo docker run --name mysql -p 3306:3306 -v /home/ubuntu/mysqlData:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=zhouwei -d mysql:5.5.54  --character-set-server=utf8 --collation-server=utf8_general_ci</p>
</blockquote>
</li>
<li><p>&#x542F;&#x52A8;Tomcat&#x670D;&#x52A1;&#x5668;&#x5E76;&#x66B4;&#x9732;&#x5728;&#x4E3B;&#x673A;&#x7684;80&#x7AEF;&#x53E3;</p>
<blockquote>
<p>mkdir webapps<br>sudo docker run --name tomcat --link mysql:mysql  -p 80:8080 -d tomcat:7.0.75-jre7  </p>
</blockquote>
</li>
<li><p>&#x8FD0;&#x884C;jenkins&#x955C;&#x50CF;</p>
<blockquote>
<p>sudo docker run --name jenkins -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker -v /home/ubuntu/webapps:/home/webapps -d weizhou/jenkins</p>
</blockquote>
</li>
<li><p>&#x67E5;&#x770B;&#x521D;&#x59CB;&#x5BC6;&#x7801;</p>
<blockquote>
<p>sudo docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword</p>
</blockquote>
</li>
<li><p>&#x6D4F;&#x89C8;&#x5668;&#x4E2D;&#x670D;&#x52A1;&#x5668;8080&#x7AEF;&#x53E3;&#x8FD0;&#x884C;jenkins&#x4E86;&#xFF0C;jenkins&#x4EFB;&#x52A1;&#x4E2D;&#x6784;&#x5EFA;&#xFF0C;</p>
</li>
<li>&#x9009;&#x62E9;<code>Invoke top-level Maven target</code>&#xFF0C;&#x8F93;&#x5165;<code>install</code><ul>
<li>&#x9009;&#x62E9;<code>Execute shell</code><ol>
<li>docker&#x5BBF;&#x4E3B;&#x673A;&#x4E3A;Ubuntu&#x586B;&#x5165;&#xFF1A;<pre class="language-"><code>sudo docker exec tomcat  /usr/local/tomcat/bin/catalina.sh stop
sudo docker rm -f tomcat
sudo cp /var/jenkins_home/workspace/rpm/target/rpm.war /home/webapps/rpm.war
sudo chmod 777 /home/webapps/rpm.war
sudo docker run --name tomcat --link mysql:mysql  -p 80:8080 -v /home/ubuntu/webapps/rpm.war:/usr/local/tomcat/webapps/rpm.war --rm -d tomcat:7.0.75-jre7
</code></pre></li>
</ol>
</li>
<li>docker&#x5BBF;&#x4E3B;&#x673A;&#x4E3A;Centos7&#x586B;&#x5165;&#xFF1A;<pre class="language-"><code>sudo docker exec tomcat  /usr/local/tomcat/bin/catalina.sh stop
sudo docker rm -f tomcat
sudo cp /var/jenkins_home/workspace/rpm/target/rpm.war /home/webapps/
sudo chmod 777 /home/webapps/rpm.war
sudo docker run --name tomcat --link mysql:mysql  -p 80:8080 -v /home/ubuntu/webapps/rpm.war:/usr/local/tomcat/webapps/rpm.war --rm -d tomcat:7.0.75-jre7
</code></pre></li>
</ul>
</li>
</ul>
<h1 id="&#x5728;&#x963F;&#x91CC;&#x4E91;&#x6784;&#x5EFA;&#x590D;&#x6742;java-web&#x5E94;&#x7528;">4. &#x5728;&#x963F;&#x91CC;&#x4E91;&#x6784;&#x5EFA;&#x590D;&#x6742;Java Web&#x5E94;&#x7528;</h1>
<ul>
<li>Jenkins&#x62F7;&#x8D1D;&#x81EA;&#x6709;&#x5305;<pre class="language-"><code>mvn install:install-file -Dfile=src/main/webapp/WEB-INF/lib/easydbo-0.9.1.jar -DgroupId=com.easyjf -DartifactId=easydbo -Dversion=0.9.1 -Dpackaging=jar
mvn install:install-file -Dfile=src/main/webapp/WEB-INF/lib/easyjf-jweb-0.9.0.jar -DgroupId=com.easyjf -DartifactId=jweb -Dversion=0.9.0 -Dpackaging=jar
mvn install:install-file -Dfile=src/main/webapp/WEB-INF/lib/QRCode.jar -DgroupId=jp.sourceforge.qrcode -DartifactId=qrcode -Dversion=0.0.1 -Dpackaging=jar
mvn install:install-file -Dfile=src/main/webapp/WEB-INF/lib/Qrcode_swetake.jar -DgroupId=com.swetake -DartifactId=Qrcode_swetake -Dversion=0.0.1 -Dpackaging=jar
mvn install:install-file -Dfile=src/main/webapp/WEB-INF/lib/IKAnalyzer3.2.8.jar -DgroupId=org.wltea -DartifactId=IKAnalyzer -Dversion=3.2.8 -Dpackaging=jar
</code></pre>==============================<h1 id="&#x5907;&#x7528;&#xFF08;&#x672A;&#x6210;&#x529F;&#x5C1D;&#x8BD5;&#x7684;&#x547D;&#x4EE4;">5. &#x5907;&#x7528;&#xFF08;&#x672A;&#x6210;&#x529F;&#x5C1D;&#x8BD5;&#x7684;&#x547D;&#x4EE4;)</h1>
</li>
</ul>
<h1 id="&#x8FD0;&#x884C;jenkins&#x670D;&#x52A1;&#x5668;">6. &#x8FD0;&#x884C;jenkins&#x670D;&#x52A1;&#x5668;</h1>
<blockquote>
<p>mkdir jenkinsHome
sudo chmod 777 jenkinsHome
sudo docker run -p 8090:8080 -p 50000:50000 -v /home/ubuntu/jenkinsHome:/var/jenkins_home jenkins
sudo docker run -p 8090:8080 -p 50000:50000 -v /home/ubuntu/jenkinsHome:/var/jenkins_home jenkins
//ssh&#x5BA2;&#x6237;&#x7AEF;&#x9009;&#x4E2D;&#x521D;&#x59CB;&#x5BC6;&#x7801;&#x70B9;&#x9F20;&#x6807;&#x53F3;&#x952E;&#x590D;&#x5236;,&#x4ECE;&#x6D4F;&#x89C8;&#x5668;&#x8FDB;&#x5165;jenkins&#x914D;&#x7F6E;&#x597D;</p>
<h1 id="&#x4F7F;&#x7528;&#x53E6;&#x4E00;&#x4E2A;ssh&#x5BA2;&#x6237;&#x7AEF;&#x767B;&#x5F55;">7. &#x4F7F;&#x7528;&#x53E6;&#x4E00;&#x4E2A;ssh&#x5BA2;&#x6237;&#x7AEF;&#x767B;&#x5F55;</h1>
<p>sudo chmod 777 gibookserver.sh
sudo chmod 777 gibookserver1.sh
mv gibookserver.sh gibookserver.sh
mv gibookserver.sh gibookserver1.sh</p>
<p>sudo docker ps -a
//&#x83B7;&#x5F97;&#x6B63;&#x5728;&#x8FD0;&#x884C;&#x7684;jenkins&#x5BB9;&#x5668;name</p>
<h1 id="&#x5C06;&#x8FD0;&#x884C;&#x811A;&#x672C;&#x62F7;&#x5165;&#x5BB9;&#x5668;">8. &#x5C06;&#x8FD0;&#x884C;&#x811A;&#x672C;&#x62F7;&#x5165;&#x5BB9;&#x5668;</h1>
<p>sudo docker inspect -f   &apos;&apos; dbe47d1b2ee2
sudo docker exec dbe chmod 777 /var/jenkins_home/gibookserver.sh
sudo docker exec dbe chmod 777 /var/jenkins_home/gibookserver1.sh</p>
<p>sudo docker cp gitbookserver.sh     dbe47d1b2ee2ae0222f760052c9138045ec8934180430c32f119c9e637f7035e:/var/jenkins_home
sudo docker cp gitbookserver1.sh     dbe47d1b2ee2ae0222f760052c9138045ec8934180430c32f119c9e637f7035e:/var/jenkins_home</p>
<p>sudo docker exec -it dbe47d1b2ee2ae0222f760052c9138045ec8934180430c32f119c9e637f7035e ls /var/jenkins_home</p>
</blockquote>
<h1 id="&#x7B2C;&#x4E8C;&#x6B21;&#x540E;&#x8FD0;&#x884C;">9. &#x7B2C;&#x4E8C;&#x6B21;&#x540E;&#x8FD0;&#x884C;</h1>
<blockquote>
<p>sudo docker run -p -d 8090:8080 -p 50000:50000 jenkins</p>
<p>sudo docker pull jenkins:2.32.2</p>
</blockquote>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; &#x5468;&#x709C; 2016-2017 &#x5982;&#x9700;&#x8F6C;&#x8F7D;&#x8BF7;&#x6807;&#x660E;&#x51FA;&#x5904; all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2018-04-02 13:28:03
</span></footer><div id="anchors-navbar"><i class="fa fa-anchor"></i><ul><p><a href="#"></a></p><li><a href="#&#x4F7F;&#x7528;docker&#x6784;&#x5EFA;jenkins&#x955C;&#x50CF;">1. &#x4F7F;&#x7528;Docker&#x6784;&#x5EFA;Jenkins&#x955C;&#x50CF;</a></li><ul><li><a href="#&#x6784;&#x5EFA;jenkins&#x955C;&#x50CF;">1.1. &#x6784;&#x5EFA;Jenkins&#x955C;&#x50CF;</a></li></ul><li><a href="#&#x4F7F;&#x7528;docker&#x955C;&#x50CF;&#x8FD0;&#x884C;gitbook&#x670D;&#x52A1;&#x5BB9;&#x5668;">2. &#x4F7F;&#x7528;Docker&#x955C;&#x50CF;&#x8FD0;&#x884C;gitbook&#x670D;&#x52A1;&#x5BB9;&#x5668;</a></li><li><a href="#&#x4F7F;&#x7528;docker&#x955C;&#x50CF;&#x8FD0;&#x884C;tomcat&#x670D;&#x52A1;&#x5BB9;&#x5668;">3. &#x4F7F;&#x7528;Docker&#x955C;&#x50CF;&#x8FD0;&#x884C;Tomcat&#x670D;&#x52A1;&#x5BB9;&#x5668;</a></li><li><a href="#&#x5728;&#x963F;&#x91CC;&#x4E91;&#x6784;&#x5EFA;&#x590D;&#x6742;java-web&#x5E94;&#x7528;">4. &#x5728;&#x963F;&#x91CC;&#x4E91;&#x6784;&#x5EFA;&#x590D;&#x6742;Java Web&#x5E94;&#x7528;</a></li><li><a href="#&#x5907;&#x7528;&#xFF08;&#x672A;&#x6210;&#x529F;&#x5C1D;&#x8BD5;&#x7684;&#x547D;&#x4EE4;">5. &#x5907;&#x7528;&#xFF08;&#x672A;&#x6210;&#x529F;&#x5C1D;&#x8BD5;&#x7684;&#x547D;&#x4EE4;)</a></li><li><a href="#&#x8FD0;&#x884C;jenkins&#x670D;&#x52A1;&#x5668;">6. &#x8FD0;&#x884C;jenkins&#x670D;&#x52A1;&#x5668;</a></li><li><a href="#&#x4F7F;&#x7528;&#x53E6;&#x4E00;&#x4E2A;ssh&#x5BA2;&#x6237;&#x7AEF;&#x767B;&#x5F55;">7. &#x4F7F;&#x7528;&#x53E6;&#x4E00;&#x4E2A;ssh&#x5BA2;&#x6237;&#x7AEF;&#x767B;&#x5F55;</a></li><li><a href="#&#x5C06;&#x8FD0;&#x884C;&#x811A;&#x672C;&#x62F7;&#x5165;&#x5BB9;&#x5668;">8. &#x5C06;&#x8FD0;&#x884C;&#x811A;&#x672C;&#x62F7;&#x5165;&#x5BB9;&#x5668;</a></li><li><a href="#&#x7B2C;&#x4E8C;&#x6B21;&#x540E;&#x8FD0;&#x884C;">9. &#x7B2C;&#x4E8C;&#x6B21;&#x540E;&#x8FD0;&#x884C;</a></li></ul></div><a href="#&#x4F7F;&#x7528;docker&#x6784;&#x5EFA;jenkins&#x955C;&#x50CF;" id="goTop"><i class="fa fa-arrow-up"></i></a>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="dockerTomcat.html" class="navigation navigation-prev " aria-label="Previous page: 基于docker运行Tomcat/MySql">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="aliyun.html" class="navigation navigation-next " aria-label="Next page: 阿里云构建服务器">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"基于docker运行Jenkins","level":"1.3.9.3","depth":3,"next":{"title":"阿里云构建服务器","level":"1.3.9.4","depth":3,"path":"programming/devops/aliyun.md","ref":"programming/devops/aliyun.md","articles":[]},"previous":{"title":"基于docker运行Tomcat/MySql","level":"1.3.9.2","depth":3,"path":"programming/devops/dockerTomcat.md","ref":"programming/devops/dockerTomcat.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-lunr","search-jieba","-highlight","prism","advanced-emoji@0.1.5","include-codeblock","ace","emphasize","katex","anchors","mermaid","tbfed-pagefooter","sectionx","expandable-chapters","codeblock-filename","local-video","splitter","duoshuo","baidu","donate","anchors","anchor-navigation-ex","image-captions"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"search-jieba":{},"tbfed-pagefooter":{"copyright":"Copyright &copy 周炜 2016-2017 如需转载请标明出处","modify_label":"该文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"prism":{"css":["prismjs/themes/prism-coy.css"]},"emphasize":{},"ace":{},"github":{"url":"https://github.com/zhangjikai/gitbook-use"},"splitter":{},"search":{},"mermaid":{},"duoshuo":{"short_name":"weigitbooktest","theme":"default"},"donate":{"alipay":"http://weizhou.coding.me/weizhou/images/ZhouWeiAlipay.png","alipayText":"支付宝打赏","button":"赏","title":"","wechat":"http://weizhou.coding.me/weizhou/images/ZhouWeiWechatPay.jpg","wechatText":"微信打赏"},"katex":{},"fontsettings":{"theme":"white","family":"sans","size":2},"sectionx":{},"anchor-navigation-ex":{"isRewritePageTitle":true},"codeblock-filename":{},"sitemap":{"hostname":"http://www.baidu.com"},"local-video":{},"baidu":{"token":"a3f08983487a96aa9943fa1394254a16"},"advanced-emoji":{"myConfigKey":"test"},"include-codeblock":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":true,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{},"expandable-chapters":{},"image-captions":{"caption":"Image _PAGE_LEVEL_._PAGE_IMAGE_NUMBER_ - _CAPTION_","variable_name":"_pictures"}},"theme":"default","author":"Zhou Wei","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{"_pictures":[{"backlink":"lecture/ssh/sshHomework.html#fig1.2.3.3.1","level":"1.2.3.3","list_caption":"Figure: SpringTest项目图","alt":"SpringTest项目图","nro":1,"url":"assets/markdown-img-paste-20170412131653323.png","index":1,"caption_template":"Image _PAGE_LEVEL_._PAGE_IMAGE_NUMBER_ - _CAPTION_","label":"SpringTest项目图","attributes":{},"skip":false,"key":"1.2.3.3.1"}]},"title":"Dr. Zhou's HOME","language":"zh-hans","links":{"sidebar":{"周炜主页":"http://weizhou.coding.me/weizhou/intro/"}},"gitbook":"3.2.2","description":"Dr. Zhou's HOME"},"file":{"path":"programming/devops/dockerJenkins.md","mtime":"2018-04-02T13:28:03.719Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2018-04-02T13:28:08.830Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-jieba/pouchdb.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-jieba/pouchdb.load.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-jieba/search-jieba.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-ace/ace/ace.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-ace/ace.js"></script>
        
    
        
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sectionx/sectionx.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-local-video/video.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-duoshuo/duoshuo.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-baidu/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

